/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aletex.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author cibervn
 */
@Entity
@Table(name = "p_privelegedobject")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PrivelegedObject.findAll", query = "SELECT p FROM PrivelegedObject p"),
    @NamedQuery(name = "PrivelegedObject.findByObjectID", query = "SELECT p FROM PrivelegedObject p WHERE p.objectID = :objectID"),
    @NamedQuery(name = "PrivelegedObject.findByObjectName", query = "SELECT p FROM PrivelegedObject p WHERE p.objectName = :objectName"),
    @NamedQuery(name = "PrivelegedObject.findByType", query = "SELECT p FROM PrivelegedObject p WHERE p.type = :type")})
public class PrivelegedObject implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ObjectID")
    private Integer objectID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "ObjectName")
    private String objectName;
    @Size(max = 50)
    @Column(name = "Type_")
    private String type;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "privelegedObject")
    private List<RolePermission> rolePermissionList;

    public PrivelegedObject() {
    }

    public PrivelegedObject(Integer objectID) {
        this.objectID = objectID;
    }

    public PrivelegedObject(Integer objectID, String objectName) {
        this.objectID = objectID;
        this.objectName = objectName;
    }

    public Integer getObjectID() {
        return objectID;
    }

    public void setObjectID(Integer objectID) {
        this.objectID = objectID;
    }

    public String getObjectName() {
        return objectName;
    }

    public void setObjectName(String objectName) {
        this.objectName = objectName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @XmlTransient
    public List<RolePermission> getRolePermissionList() {
        return rolePermissionList;
    }

    public void setRolePermissionList(List<RolePermission> rolePermissionList) {
        this.rolePermissionList = rolePermissionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (objectID != null ? objectID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PrivelegedObject)) {
            return false;
        }
        PrivelegedObject other = (PrivelegedObject) object;
        if ((this.objectID == null && other.objectID != null) || (this.objectID != null && !this.objectID.equals(other.objectID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "aletex.entity.PrivelegedObject[ objectID=" + objectID + " ]";
    }
    
}
